﻿using System;
using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.Security;

using ChiDao.Component.Utils;
using ChiDao.Business.Models;
using ChiDao.Business.Models.FlowProcess;
using ChiDao.Site.Models;
using ChiDao.Business.Data.Repositories.Account;
using ChiDao.Business.Models.Account;


namespace ChiDao.Business.Service.Impl
{
    [Export(typeof(IOrgService))]
    internal class OrgService : IOrgService
    {
        [Import]
        protected IOrgRepository OrgRepository { get; set; }

        public IQueryable<Org> Orgs
        {
            get { return OrgRepository.Entities; }
        }

        public OperationResult Add(OrgView viewModel)
        {
            PublicHelper.CheckArgument(viewModel, "viewModel");
            Org model = viewModel.CopyTo<Org>();
            OrgRepository.Insert(model, true);
            return new OperationResult(OperationResultType.Success, "保存成功", viewModel);
        }
    }
}